package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Code() {
	@layouts.DocsLayout(
		"Code",
		"Code displays a code block with optional syntax highlighting and copy functionality.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				Text: "Examples",
				ID:   "examples",
				Children: []modules.TableOfContentsItem{
					{
						Text: "Copy Button",
						ID:   "copy-button",
					},
				},
			},
			{
				ID:   "api-reference",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						Text: "Code",
						ID:   "code",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Code",
			Description: templ.Raw("Code displays a code block with optional syntax highlighting and copy functionality"),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Code",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.CodeDefault(),
				PreviewCodeFile: "code_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "code",
					JSFiles:       []string{"code"},
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Copy Button",
					ShowcaseFile:    showcase.CodeCopyButton(),
					PreviewCodeFile: "code_copy_button.templ",
					ID:              "copy-button",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api-reference",
			}) {
				@modules.APILegend()
				<div id="code">
					@modules.APITable(modules.APITableProps{
						Title:       "Code",
						Description: "API reference for the Code component.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "code-{randomID}",
								Description: "Unique identifier for the code component",
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "\"\"",
								Description: "Additional CSS classes to apply to the code container",
							},
							{
								Name:        "Attrs",
								Type:        "templ.Attributes",
								Default:     "nil",
								Description: "Additional HTML attributes to apply to the code container",
							},
							{
								Name:        "Language",
								Type:        "string",
								Default:     "\"\"",
								Description: "Programming language for syntax highlighting",
							},
							{
								Name:        "CodeClass",
								Type:        "string",
								Default:     "\"\"",
								Description: "Additional CSS classes to apply to the code element",
							},
						},
					})
				</div>
			}
		}
	}
}
